package co.gov.medellin.ssti.sub.model.dao;

import java.util.Collection;
import java.util.Vector;

import javax.ejb.SessionBean;
import javax.ejb.SessionContext;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.rmi.PortableRemoteObject;

import co.gov.medellin.ssti.sub.paoyer.administration.AdministrationMngr;
import co.gov.medellin.ssti.sub.paoyer.administration.model.vo.ApplicationUserVO;
import co.gov.medellin.ssti.sub.paoyer.administration.model.vo.ApplicationVO;
import co.gov.medellin.ssti.sub.paoyer.administration.model.vo.AuthorizedByBranchVO;
import co.gov.medellin.ssti.sub.paoyer.administration.model.vo.ContractVO;
import co.gov.medellin.ssti.sub.paoyer.administration.model.vo.CostCenterByAuthorizedVO;
import co.gov.medellin.ssti.sub.paoyer.administration.model.vo.FDClassVO;
import co.gov.medellin.ssti.sub.paoyer.administration.model.vo.FDTypeVO;
import co.gov.medellin.ssti.sub.paoyer.administration.model.vo.FDVO;
import co.gov.medellin.ssti.sub.paoyer.administration.model.vo.FlexValueVO;
import co.gov.medellin.ssti.sub.paoyer.administration.model.vo.OptionVO;
import co.gov.medellin.ssti.sub.paoyer.administration.model.vo.ProgramParameterVO;
import co.gov.medellin.ssti.sub.paoyer.administration.model.vo.ProgramVO;
import co.gov.medellin.ssti.sub.paoyer.administration.model.vo.UserGroupOptionVO;
import co.gov.medellin.ssti.sub.paoyer.administration.model.vo.UserGroupVO;
import co.gov.medellin.ssti.sub.paoyer.administration.model.vo.UserVO;
import co.gov.medellin.ssti.sub.paoyer.administration.model.vo.WarehouseByBranchVO;

public class AdministrationFacadeLocalBean implements SessionBean {
	public void ejbCreate() {
	}

	public void ejbActivate() {
	}

	public void ejbPassivate() {
	}

	public void ejbRemove() {
	}

	public void setSessionContext(SessionContext ctx) {
	}

	public UserVO authenticateUser(UserVO user) {
		AdministrationMngr manager = new AdministrationMngr();
		return manager.authenticateUser(user);
	}

	public String getMenu(String strUserGroup, String strPath) {
		AdministrationMngr manager = new AdministrationMngr();
		return manager.getMenu(strUserGroup, strPath);
	}

	public Vector getResources(UserVO user) {
		AdministrationMngr manager = new AdministrationMngr();
		return manager.getResources(user);
	}

	public UserVO userGroup(UserVO user) {
		AdministrationMngr manager = new AdministrationMngr();
		return manager.userGroup(user);
	}

	public Collection findUserByCriterea(UserVO user) {
		AdministrationMngr manager = new AdministrationMngr();
		return manager.findUserByCriterea(user);
	}

	public boolean createUser(UserVO user) {
		AdministrationMngr manager = new AdministrationMngr();
		return manager.createUser(user);
	}

	public boolean updateUser(UserVO user) {
		AdministrationMngr manager = new AdministrationMngr();
		return manager.updateUser(user);
	}

	public boolean deleteUser(UserVO user) {
		AdministrationMngr manager = new AdministrationMngr();
		return manager.deleteUser(user);
	}

	// ------------------------------------------------------------------------------

	public ApplicationVO createApplication(ApplicationVO application) {
		AdministrationMngr manager = new AdministrationMngr();
		return manager.createApplication(application);
	}

	public Collection findApplicationByCriterea(ApplicationVO application) {
		AdministrationMngr manager = new AdministrationMngr();
		return manager.findApplicationByCriterea(application);
	}

	public int updateApplication(ApplicationVO application) {
		AdministrationMngr manager = new AdministrationMngr();
		return manager.updateApplication(application);
	}

	public int deleteApplication(ApplicationVO application) {
		AdministrationMngr manager = new AdministrationMngr();
		return manager.deleteApplication(application);
	}

	public UserGroupVO createUserGroup(UserGroupVO userGroup) {
		AdministrationMngr manager = new AdministrationMngr();
		return manager.createUserGroup(userGroup);
	}

	public Collection findUserGroupByCriterea(UserGroupVO userGroup) {
		AdministrationMngr manager = new AdministrationMngr();
		return manager.findUserGroupByCriterea(userGroup);
	}

	public UserGroupVO updateUserGroup(UserGroupVO userGroup) {
		AdministrationMngr manager = new AdministrationMngr();
		return manager.updateUserGroup(userGroup);
	}

	public void deleteUserGroup(UserGroupVO userGroup) {
		AdministrationMngr manager = new AdministrationMngr();
		manager.deleteUserGroup(userGroup);
	}

	public OptionVO createOption(OptionVO option) {
		AdministrationMngr manager = new AdministrationMngr();
		return manager.createOption(option);
	}

	public Collection findOptionByCriterea(OptionVO option) {
		AdministrationMngr manager = new AdministrationMngr();
		return manager.findOptionByCriterea(option);
	}

	public OptionVO updateOption(OptionVO option) {
		AdministrationMngr manager = new AdministrationMngr();
		return manager.updateOption(option);
	}

	public void deleteOption(OptionVO option) {
		AdministrationMngr manager = new AdministrationMngr();
		manager.deleteOption(option);
	}

	public ProgramVO createProgram(ProgramVO program) {
		AdministrationMngr manager = new AdministrationMngr();
		return manager.createProgram(program);
	}

	public Collection findProgramByCriterea(ProgramVO program) {
		AdministrationMngr manager = new AdministrationMngr();
		return manager.findProgramByCriterea(program);
	}

	public ProgramVO updateProgram(ProgramVO program) {
		AdministrationMngr manager = new AdministrationMngr();
		return manager.updateProgram(program);
	}

	public void deleteProgram(ProgramVO program) {
		AdministrationMngr manager = new AdministrationMngr();
		manager.deleteProgram(program);
	}

	public ProgramParameterVO createProgramParameter(
			ProgramParameterVO programParameter) {
		AdministrationMngr manager = new AdministrationMngr();
		return manager.createProgramParameter(programParameter);
	}

	public Collection findProgramParameterByCriterea(
			ProgramParameterVO programParameter) {
		AdministrationMngr manager = new AdministrationMngr();
		return manager.findProgramParameterByCriterea(programParameter);
	}

	public ProgramParameterVO updateProgramParameter(
			ProgramParameterVO programParameter) {
		AdministrationMngr manager = new AdministrationMngr();
		return manager.updateProgramParameter(programParameter);
	}

	public void deleteProgramParameter(ProgramParameterVO programParameter) {
		AdministrationMngr manager = new AdministrationMngr();
		manager.deleteProgramParameter(programParameter);
	}

	public UserGroupOptionVO createUserGroupOption(
			UserGroupOptionVO userGroupOption) {
		AdministrationMngr manager = new AdministrationMngr();
		return manager.createUserGroupOption(userGroupOption);
	}

	public Collection findNotAsociatedOptionByCriterea(
			UserGroupOptionVO userGroupOption) {
		AdministrationMngr manager = new AdministrationMngr();
		return manager.findNotAsociatedOptionByCriterea(userGroupOption);
	}

	public boolean asociateOptionToUserGroup(UserGroupOptionVO userGroupOption) {
		AdministrationMngr manager = new AdministrationMngr();
		return manager.asociateOptionToUserGroup(userGroupOption);
	}

	public Collection findUserGroupOptionByCriterea(
			UserGroupOptionVO userGroupOption) {
		AdministrationMngr manager = new AdministrationMngr();
		return manager.findUserGroupOptionByCriterea(userGroupOption);
	}

	public UserGroupOptionVO updateUserGroupOption(
			UserGroupOptionVO userGroupOption) {
		AdministrationMngr manager = new AdministrationMngr();
		return manager.updateUserGroupOption(userGroupOption);
	}

	public void deleteUserGroupOption(UserGroupOptionVO userGroupOption) {
		AdministrationMngr manager = new AdministrationMngr();
		manager.deleteUserGroupOption(userGroupOption);
	}

	public ApplicationUserVO createApplicationUser(
			ApplicationUserVO applicationUser) {
		AdministrationMngr manager = new AdministrationMngr();
		return manager.createApplicationUser(applicationUser);
	}

	public Collection findApplicationUserByCriterea(
			ApplicationUserVO applicationUser) {
		AdministrationMngr manager = new AdministrationMngr();
		return manager.findApplicationUserByCriterea(applicationUser);
	}

	public Collection findUserNotAsociatedByCriterea(ApplicationUserVO criterea) {
		AdministrationMngr manager = new AdministrationMngr();
		return manager.findUserNotAsociatedByCriterea(criterea);
	}

	public ApplicationUserVO updateApplicationUser(
			ApplicationUserVO applicationUser) {
		AdministrationMngr manager = new AdministrationMngr();
		return manager.updateApplicationUser(applicationUser);
	}

	public void deleteApplicationUser(ApplicationUserVO applicationUser) {
		AdministrationMngr manager = new AdministrationMngr();
		manager.deleteApplicationUser(applicationUser);
	}

	public FlexValueVO createFlexValue(FlexValueVO flexValue) {
		AdministrationMngr manager = new AdministrationMngr();
		return manager.createFlexValue(flexValue);
	}

	public Collection findFlexValueByCriterea(FlexValueVO flexValue) {
		AdministrationMngr manager = new AdministrationMngr();
		return manager.findFlexValueByCriterea(flexValue);
	}

	public boolean updateFlexValue(FlexValueVO flexValue) {
		AdministrationMngr manager = new AdministrationMngr();
		return manager.updateFlexValue(flexValue);
	}

	public boolean deleteFlexValue(FlexValueVO flexValue) {
		AdministrationMngr manager = new AdministrationMngr();
		return manager.deleteFlexValue(flexValue);
	}

	public Collection findFlexValueTypeByCriterea(FlexValueVO criterea) {
		AdministrationMngr manager = new AdministrationMngr();
		return manager.findFlexValueTypeByCriterea(criterea);
	}

	public FlexValueVO createFlexValueType(FlexValueVO flexValueType) {
		AdministrationMngr manager = new AdministrationMngr();
		return manager.createFlexValueType(flexValueType);
	}

	public boolean updateFlexValueType(FlexValueVO flexValueType) {
		AdministrationMngr manager = new AdministrationMngr();
		return manager.updateFlexValueType(flexValueType);
	}

	public boolean deleteFlexValueType(FlexValueVO flexValueType) {
		AdministrationMngr manager = new AdministrationMngr();
		return manager.deleteFlexValueType(flexValueType);
	}

	// Consultas
	public Collection findInventoryByCriterea(FDVO fd) {
		AdministrationMngr manager = new AdministrationMngr();
		return manager.findInventoryByCriterea(fd);
	}

	public Collection findContractByCriterea(ContractVO criterea) {
		AdministrationMngr manager = new AdministrationMngr();
		return manager.findContractByCriterea(criterea);
	}

	public Collection findAuthorizedBranchByCriterea(
			AuthorizedByBranchVO authorizedByBranch) {
		AdministrationMngr manager = new AdministrationMngr();
		return manager.findAuthorizedBranchByCriterea(authorizedByBranch);
	}

	public Collection findWarehouseBranchByCriterea(
			WarehouseByBranchVO warehouseByBranch) {
		AdministrationMngr manager = new AdministrationMngr();
		return manager.findWarehouseBranchByCriterea(warehouseByBranch);
	}

	public Collection findCostCenterAuthorizedByCriterea(
			CostCenterByAuthorizedVO costCenterByAuthorized) {
		AdministrationMngr manager = new AdministrationMngr();
		return manager
				.findCostCenterAuthorizedByCriterea(costCenterByAuthorized);
	}

	public Collection findFDClassByCriterea(FDClassVO fdClass) {
		AdministrationMngr manager = new AdministrationMngr();
		return manager.findFDClassByCriterea(fdClass);
	}

	public Collection findFDTypeByCriterea(FDTypeVO fdType) {
		AdministrationMngr manager = new AdministrationMngr();
		return manager.findFDTypeByCriterea(fdType);
	}

	public Collection findFDHistoryByCriterea(FDVO fdVO) {
		AdministrationMngr manager = new AdministrationMngr();
		return manager.findFDHistoryByCriterea(fdVO);
	}

	private AdministrationFacadeLocalHome getAdministrationFacadeHome()
			throws NamingException {
		final InitialContext context = new InitialContext();
		return (AdministrationFacadeLocalHome) PortableRemoteObject.narrow(
				context.lookup("java:comp/env/AdministrationFacadeLocal"),
				AdministrationFacadeLocalHome.class);
	}

	private AdministrationFacadeLocalLocalHome getAdministrationFacadeLocalLocalHome()
			throws NamingException {
		final InitialContext context = new InitialContext();
		return (AdministrationFacadeLocalLocalHome) context
				.lookup("java:comp/env/ejb/local/AdministrationFacadeLocal");
	}
}